<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BadgerDB: /home/ubuntu/study/dbmslab/lab2/BufMgr/src/file_iterator.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BadgerDB
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_43e0a1f539e00dcfa1a6bc4d4fee4fc2.html">home</a></li><li class="navelem"><a class="el" href="dir_f895279abf3c9abddbac24b9a320b4c6.html">ubuntu</a></li><li class="navelem"><a class="el" href="dir_9223221a80e1dde112a2f0d1c0d6bc8d.html">study</a></li><li class="navelem"><a class="el" href="dir_565d95caf30f979632cef261ad9a6ed4.html">dbmslab</a></li><li class="navelem"><a class="el" href="dir_04bc7b587b42191e49c8f970037360ad.html">lab2</a></li><li class="navelem"><a class="el" href="dir_ccc57109e70d5b9b219c75d9ecb5bc70.html">BufMgr</a></li><li class="navelem"><a class="el" href="dir_57419356550b183f8cb4d89f81ab51b6.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">file_iterator.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &quot;file.h&quot;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &quot;page.h&quot;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;types.h&quot;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacebadgerdb.html">badgerdb</a> {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html">   23</a></span>&#160;<span class="keyword">class </span><a class="code" href="classbadgerdb_1_1_file_iterator.html">FileIterator</a> {</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html#a99bd5c0e0fac0493f9664409219ca88e">   28</a></span>&#160;  <a class="code" href="classbadgerdb_1_1_file_iterator.html#a99bd5c0e0fac0493f9664409219ca88e">FileIterator</a>()</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;      : file_(NULL),</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        current_page_number_(<a class="code" href="classbadgerdb_1_1_page.html">Page</a>::INVALID_NUMBER) {</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;  }</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html#ad286fc916be769b1bea154603b83ece0">   39</a></span>&#160;  <a class="code" href="classbadgerdb_1_1_file_iterator.html#ad286fc916be769b1bea154603b83ece0">FileIterator</a>(<a class="code" href="classbadgerdb_1_1_file.html">File</a>* file)</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;      : file_(file) {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    assert(file_ != NULL);</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_file_header.html">FileHeader</a>&amp; header = file_-&gt;readHeader();</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    current_page_number_ = header.<a class="code" href="structbadgerdb_1_1_file_header.html#ad006b5b9d02b8c20e7ad5226680779c6">first_used_page</a>;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  }</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html#afabd7eecd315a85f9eb602f71c6f88e3">   53</a></span>&#160;  <a class="code" href="classbadgerdb_1_1_file_iterator.html#afabd7eecd315a85f9eb602f71c6f88e3">FileIterator</a>(<a class="code" href="classbadgerdb_1_1_file.html">File</a>* file, <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> page_number)</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;      : file_(file),</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        current_page_number_(page_number) {</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  }</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html#a6fa0f1cef8b46bb933ce6f000276ab52">   61</a></span>&#160;  <span class="keyword">inline</span> <a class="code" href="classbadgerdb_1_1_file_iterator.html">FileIterator</a>&amp; <a class="code" href="classbadgerdb_1_1_file_iterator.html#a6fa0f1cef8b46bb933ce6f000276ab52">operator++</a>() {</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    assert(file_ != NULL);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_page_header.html">PageHeader</a>&amp; header = file_-&gt;readPageHeader(current_page_number_);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    current_page_number_ = header.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a>;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160; </div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  }</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160; </div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;  <span class="comment">//postfix</span></div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;  <span class="keyword">inline</span> <a class="code" href="classbadgerdb_1_1_file_iterator.html">FileIterator</a> <a class="code" href="classbadgerdb_1_1_file_iterator.html#a6fa0f1cef8b46bb933ce6f000276ab52">operator++</a>(<span class="keywordtype">int</span>)</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  {</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <a class="code" href="classbadgerdb_1_1_file_iterator.html">FileIterator</a> tmp = *<span class="keyword">this</span>;   <span class="comment">// copy ourselves</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160; </div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    assert(file_ != NULL);</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_page_header.html">PageHeader</a>&amp; header = file_-&gt;readPageHeader(current_page_number_);</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    current_page_number_ = header.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a>;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160; </div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keywordflow">return</span> tmp;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  }</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html#a5eff20ca4457438dd7ba2a09ec87703a">   87</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classbadgerdb_1_1_file_iterator.html#a5eff20ca4457438dd7ba2a09ec87703a">operator==</a>(<span class="keyword">const</span> <a class="code" href="classbadgerdb_1_1_file_iterator.html">FileIterator</a>&amp; rhs)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    <span class="keywordflow">return</span> file_-&gt;<a class="code" href="classbadgerdb_1_1_file.html#af16040a60f18c99305348077ac9e8aa8">filename</a>() == rhs.file_-&gt;<a class="code" href="classbadgerdb_1_1_file.html#af16040a60f18c99305348077ac9e8aa8">filename</a>() &amp;&amp;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        current_page_number_ == rhs.current_page_number_;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  }</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160; </div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> <a class="code" href="classbadgerdb_1_1_file_iterator.html">FileIterator</a>&amp; rhs)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keywordflow">return</span> (file_-&gt;<a class="code" href="classbadgerdb_1_1_file.html#af16040a60f18c99305348077ac9e8aa8">filename</a>() != rhs.file_-&gt;<a class="code" href="classbadgerdb_1_1_file.html#af16040a60f18c99305348077ac9e8aa8">filename</a>()) ||</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;        (current_page_number_ != rhs.current_page_number_);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;  }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160; </div>
<div class="line"><a name="l00103"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_file_iterator.html#ab251231092c7b7b6895b82f44c24e832">  103</a></span>&#160;  <span class="keyword">inline</span> <a class="code" href="classbadgerdb_1_1_page.html">Page</a> <a class="code" href="classbadgerdb_1_1_file_iterator.html#ab251231092c7b7b6895b82f44c24e832">operator*</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;<span class="keyword">  </span>{ <span class="keywordflow">return</span> file_-&gt;<a class="code" href="classbadgerdb_1_1_file.html#a343b7fb1a238992f02454e9e81837acd">readPage</a>(current_page_number_); }</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160; </div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;  <a class="code" href="classbadgerdb_1_1_file.html">File</a>* file_;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160; </div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;  <a class="code" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> current_page_number_;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;};</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160; </div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="anamespacebadgerdb_html"><div class="ttname"><a href="namespacebadgerdb.html">badgerdb</a></div><div class="ttdef"><b>Definition:</b> <a href="buffer_8cpp_source.html#l00017">buffer.cpp:17</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html">badgerdb::PageHeader</a></div><div class="ttdoc">Header metadata in a page.</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00025">page.h:25</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a7cb8260dedb0748d3d75c4b1722dcf3c"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">badgerdb::PageHeader::next_page_number</a></div><div class="ttdeci">PageId next_page_number</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00058">page.h:58</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_file_header_html"><div class="ttname"><a href="structbadgerdb_1_1_file_header.html">badgerdb::FileHeader</a></div><div class="ttdoc">Header metadata for files on disk which contain pages.</div><div class="ttdef"><b>Definition:</b> <a href="file_8h_source.html#l00024">file.h:24</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html_a99bd5c0e0fac0493f9664409219ca88e"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html#a99bd5c0e0fac0493f9664409219ca88e">badgerdb::FileIterator::FileIterator</a></div><div class="ttdeci">FileIterator()</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00028">file_iterator.h:28</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html_a6fa0f1cef8b46bb933ce6f000276ab52"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html#a6fa0f1cef8b46bb933ce6f000276ab52">badgerdb::FileIterator::operator++</a></div><div class="ttdeci">FileIterator &amp; operator++()</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00061">file_iterator.h:61</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_html"><div class="ttname"><a href="classbadgerdb_1_1_file.html">badgerdb::File</a></div><div class="ttdoc">Class which represents a file in the filesystem containing database pages.</div><div class="ttdef"><b>Definition:</b> <a href="file_8h_source.html#l00073">file.h:73</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html_ad286fc916be769b1bea154603b83ece0"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html#ad286fc916be769b1bea154603b83ece0">badgerdb::FileIterator::FileIterator</a></div><div class="ttdeci">FileIterator(File *file)</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00039">file_iterator.h:39</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html_ab251231092c7b7b6895b82f44c24e832"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html#ab251231092c7b7b6895b82f44c24e832">badgerdb::FileIterator::operator*</a></div><div class="ttdeci">Page operator*() const</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00103">file_iterator.h:103</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_file_header_html_ad006b5b9d02b8c20e7ad5226680779c6"><div class="ttname"><a href="structbadgerdb_1_1_file_header.html#ad006b5b9d02b8c20e7ad5226680779c6">badgerdb::FileHeader::first_used_page</a></div><div class="ttdeci">PageId first_used_page</div><div class="ttdef"><b>Definition:</b> <a href="file_8h_source.html#l00033">file.h:33</a></div></div>
<div class="ttc" id="anamespacebadgerdb_html_a1f49e404293bf4240756b89b53b1587a"><div class="ttname"><a href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">badgerdb::PageId</a></div><div class="ttdeci">std::uint32_t PageId</div><div class="ttdoc">Identifier for a page in a file.</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00015">types.h:15</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html"><div class="ttname"><a href="classbadgerdb_1_1_page.html">badgerdb::Page</a></div><div class="ttdoc">Class which represents a fixed-size database page containing records.</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00107">page.h:107</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_html_af16040a60f18c99305348077ac9e8aa8"><div class="ttname"><a href="classbadgerdb_1_1_file.html#af16040a60f18c99305348077ac9e8aa8">badgerdb::File::filename</a></div><div class="ttdeci">const std::string &amp; filename() const</div><div class="ttdef"><b>Definition:</b> <a href="file_8h_source.html#l00179">file.h:179</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html_a5eff20ca4457438dd7ba2a09ec87703a"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html#a5eff20ca4457438dd7ba2a09ec87703a">badgerdb::FileIterator::operator==</a></div><div class="ttdeci">bool operator==(const FileIterator &amp;rhs) const</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00087">file_iterator.h:87</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_html_a343b7fb1a238992f02454e9e81837acd"><div class="ttname"><a href="classbadgerdb_1_1_file.html#a343b7fb1a238992f02454e9e81837acd">badgerdb::File::readPage</a></div><div class="ttdeci">Page readPage(const PageId page_number) const</div><div class="ttdef"><b>Definition:</b> <a href="file_8cpp_source.html#l00149">file.cpp:149</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html_afabd7eecd315a85f9eb602f71c6f88e3"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html#afabd7eecd315a85f9eb602f71c6f88e3">badgerdb::FileIterator::FileIterator</a></div><div class="ttdeci">FileIterator(File *file, PageId page_number)</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00053">file_iterator.h:53</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_file_iterator_html"><div class="ttname"><a href="classbadgerdb_1_1_file_iterator.html">badgerdb::FileIterator</a></div><div class="ttdoc">Iterator for iterating over the pages in a file.</div><div class="ttdef"><b>Definition:</b> <a href="file__iterator_8h_source.html#l00023">file_iterator.h:23</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
